/** * @license * Copyright (c) 2014, 2018, Oracle and/or its affiliates. * The Universal Permissive License (UPL), Version 1.0 */ "use strict";define(["ojs/ojcore"],function(t){var e=function(e){this.NOT_A_KEY={},this.has=function(t){return this.get(t)!==this.NOT_A_KEY},this.get=function(e){var n,r,i=this.NOT_A_KEY,o=this;if(this._keys.has(e))return e;if(e!==Object(e))return this.NOT_A_KEY;if("function"==typeof Symbol&&"function"==typeof Set.prototype[Symbol.iterator])for(r=(n=this._keys[Symbol.iterator]()).next();!r.done;){if(t.Object.compareValues(r.value,e)||r.value===e)return r.value;r=n.next()}else this._keys.forEach(function(n){(i===o.NOT_A_KEY&&t.Object.compareValues(n,e)||n===e)&&(i=n)});return i},this.InitializeWithKeys=function(t){this._keys=this._populate(t)},this._populate=function(t){var e=new Set(t);return null!=t&&0===e.size&&t.forEach(function(t){e.add(t)}),e},this.InitializeWithKeys(e)};t.KeySetImpl=e;var n=function(){this._map=new Map,this._keyset=new e},r=n.prototype;Object.defineProperty(r,"size",{get:function(){return this._map.size}}),r.clear=function(){this._map.clear(),this._keyset._keys.clear()},r.delete=function(t){var e=this._keyset.get(t);return e!==this._keyset.NOT_A_KEY&&(this._keyset._keys.delete(e),this._map.delete(e))},r.forEach=function(t){this._map.forEach(t)},r.get=function(t){var e=this._keyset.get(t);return this._map.get(e)},r.has=function(t){return this._keyset.has(t)},r.set=function(t,e){var n=this._keyset.get(t);return n===this._keyset.NOT_A_KEY?(this._keyset._keys.add(t),this._map.set(t,e)):this._map.set(n,e),this},t.Map=n;var i=function(){};t.Object.createSubclass(i,t.Object,"KeySet"),t.KeySet=i,i.prototype.SetInternal=function(t){this._keys=t},i.prototype.AddOrDeleteInternal=function(t,e){var n,r;return null==(n=t?this._add(e):this._remove(e))?this:((r=Object.create(Object.getPrototypeOf(this))).SetInternal(n),r)},i.prototype._add=function(t){var e=this,n=null;return t.forEach(function(t){t!==e.NOT_A_KEY&&e.get(t)===e.NOT_A_KEY&&(null==n&&(n=e.Clone()),n.add(t))}),n},i.prototype._remove=function(t){var e,n=this,r=null;return 0==this._keys.size?null:(t.forEach(function(t){(e=n.get(t))!==n.NOT_A_KEY&&(null==r&&(r=n.Clone()),r.delete(e))}),r)},i.prototype.GetInternalSize=function(){return this._keys.size},i.prototype.Clone=function(){return this._populate(this._keys)},e.call(i.prototype);var o=function(t){this.InitializeWithKeys(t)};t.Object.createSubclass(o,i,"ExpandedKeySet"),t.ExpandedKeySet=o,o.prototype.add=function(t){return this.AddOrDeleteInternal(!0,t)},o.prototype.addAll=function(){return new s},o.prototype.isAddAll=function(){return!1},o.prototype.delete=function(t){return this.AddOrDeleteInternal(!1,t)},o.prototype.clear=function(){return 0==this.GetInternalSize()?this:new o},o.prototype.has=function(t){return this.get(t)!==this.NOT_A_KEY},o.prototype.values=function(){return this.Clone()};var s=function(){this.InitializeWithKeys(null)};return t.Object.createSubclass(s,i,"ExpandAllKeySet"),t.ExpandAllKeySet=s,s.prototype.add=function(t){return this.AddOrDeleteInternal(!1,t)},s.prototype.addAll=function(){return 0==this.GetInternalSize()?this:new s},s.prototype.isAddAll=function(){return!0},s.prototype.delete=function(t){return this.AddOrDeleteInternal(!0,t)},s.prototype.clear=function(){return new o},s.prototype.has=function(t){return this.get(t)===this.NOT_A_KEY},s.prototype.deletedValues=function(){return this.Clone()},{KeySet:i,ExpandedKeySet:o,ExpandAllKeySet:s}});